/*
 * Кратчайший путь
 * vim:foldmethod=marker:
 */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define N_MAX	100000
#define M_MAX	500000

struct queue {
	int	*data;
	int	head;
	int	size;
	int	size_max;
};

struct Node {
	int x;
	int8_t is_valid;
	int edge_i;
	Node *next;
};

struct adjlist {
	Node	*first;
	Node	*last;
	int8_t	size;
	uint8_t	visited;

	/* Other attributes */
	int	color;
	int	distance;
	int	conn_sp_id;
	uint8_t	has_bridge;

	/* bfs */
	int	dist;
	int	prev;
};


static int _path[N_MAX + 1];
static int _path_idx = 0;

void
queue_init(struct queue *q, int size)
{
	q->data = (int *) calloc(size, sizeof *q->data);
	q->head = 0;
	q->size = 0;
	q->size_max = size;
}

void
enqueue(struct queue *q, int x)
{
	if (q->size >= q->size_max)
		fprintf(stderr, "queue overflow. failed to add x=%d\n", x);
	else
		q->data[(q->head + q->size++) % q->size_max] = x;
}

int
dequeue(struct queue *q)
{
	int ret = q->data[q->head % q->size_max];
	if (!q->size)
		return ret; /* a.k.a. UB */
	--q->size;
	if (++q->head == q->size_max)
		q->head = 0;
	return ret;
}

unsigned char
queue_isempty(struct queue *q)
{
	return (q->size > 0) ? 0 : 1;
}

void
pushback(struct adjlist *al, int x, int edge_i)
{
	struct Node *newnode;
	newnode = (struct Node *) calloc(1UL, sizeof (struct Node));
	newnode->x        = x;
	newnode->is_valid = 1;
	newnode->edge_i   = edge_i;
	newnode->next     = NULL;
	if (!al->first)
		al->first = newnode;
	else
		al->last->next = newnode;
	al->last = newnode;
	al->size++;
}

void
free_al(struct adjlist *al)
{
	struct Node *n, *p;
	p = n = al->first;
	while (n) {
		n = n->next;
		free(p);
		p = n;
	}
}

void
print_path(const struct adjlist *al, const int fin_idx)
{
	register int i = fin_idx;

	while (i != -1) {
		_path[_path_idx++] = i;
		i = al[i].prev;
	}

	(void) printf("%d\n", _path_idx - 1);
	for (i = _path_idx - 1; i >= 0; i--)
		(void) printf("%d ", _path[i] + 1);
	putchar('\n');
}

int
bfs(struct adjlist *al, struct queue *q, const int index, const int final)
{
	int u = 0;
	Node *node = NULL;

	if (index == final) {
		(void) printf("0\n%d\n", final + 1); //XXX
		return 0;
	}

	al[index].visited = 1;
	al[index].prev	  = -1;
	al[index].dist	  = 0;
	enqueue(q, index);

	while (!queue_isempty(q)) {
		u = dequeue(q);
		node = al[u].first;
		while (node) {
			if (node->x == final) {
				al[node->x].dist = al[u].dist + 1;
				al[node->x].prev = u;
				print_path(al, final);
				return 0;
			}
			if (!al[node->x].visited) {
				al[node->x].visited = 1;
				al[node->x].dist = al[u].dist + 1;
				al[node->x].prev = u;
				enqueue(q, node->x);
			}
			node = node->next;
		}
	}
	return -1;
}

int
main(void)
{
	static struct queue q;
	struct adjlist *al;
	int n, m, start, finish;
	int i;
	int a, b;

	(void) scanf("%d%d%d%d", &n, &m, &start, &finish);
	start--, finish--;
	queue_init(&q, n);
	al = (adjlist *) calloc(n, sizeof *al);

	for (i = 0; i < m; i++) {
		(void) scanf("%d%d", &a, &b);
		--a,b--;
		pushback(al + a, b, i);
	}

	if (bfs(al, &q, start, finish) == -1)
		(void) printf("-1\n");

exit:
	free(q.data);
	for (i = 0; i < n; i++)
		free_al(al + i);
	free(al);
	return 0;
}
